package principle;

import lombok.extern.slf4j.Slf4j;

/**
 * 锁重入
 */
@Slf4j
public class lock1 {
    private static final Object lock = new Object();
    public static void main(String[] args) {
        Thread t1 = new Thread("t1") {
            @Override
            public void run() {
                method1();
            }
        };

        t1.start();
    }


    public static void method1(){
        synchronized (lock){
            log.debug("我是method1");
            method2();
            log.debug("执行完毕");
        }
    }


    public static void method2(){
        synchronized (lock){
            log.debug("我是method2");
        }
    }

}
